#include "targetview.h"

TargetView::TargetView(QWidget *parent)
    : QWidget{parent}
{
    setUI();
}

void TargetView::setUI()
{
    vLayout = new QVBoxLayout();
    vLayout->setContentsMargins(0,0,0,0);
    vLayout->setSpacing(0);
    setLayout(vLayout);

    //停留时间
    dwellTimeString = new QLabel();
    dwellTimeString->setText("0");
    dwellTimeString->setAlignment(Qt::AlignCenter);
    dwellTimeString->setObjectName("dwellTimeString");

    //距离
    distanceString = new QLabel();
    distanceString->setText("650 m");
    distanceString->setAlignment(Qt::AlignCenter);
    distanceString->setObjectName("distanceString");

    //进度条
    barWidget = new QWidget();

    vernierView = new QWidget(barWidget);
    vernierView->setGeometry(4,0,40,231);

    vVernierLayout = new QVBoxLayout();
    vVernierLayout->setContentsMargins(0,0,0,0);
    vVernierLayout->setSpacing(0);
    vVernierLayout->setAlignment(Qt::AlignTop);
    vernierView->setLayout(vVernierLayout);
    QList <QString>list;
    list<<"300"<<"200"<<""<<"100"<<""<<"0m";
    for (int i = 0; i < list.length(); i++) {
        vernierWidget[i] = new VernierWidget(list[i]);
        int hValue = 0;
        if(i<1){
            hValue = 14;
        }else if(i>=1 && i<3){
            hValue = 25;
        }else{
            hValue = 70;
        }
        vVernierSpacer[i] = new QSpacerItem(10, hValue,QSizePolicy::Expanding,QSizePolicy::Minimum);
        vernierWidget[i]->setFixedSize(40,10);
        vVernierLayout->addWidget(vernierWidget[i]);
        if(i<5){
            vVernierLayout->addSpacerItem(vVernierSpacer[i]);
        }

    }

    progressBar = new QProgressBar(barWidget);
    progressBar->setGeometry(45,0,12,231);
    progressBar->setRange(0, 100);
    progressBar->setMinimum(0);  // 最小值
    progressBar->setMaximum(100);  // 最大值
    progressBar->setOrientation(Qt::Vertical);
    progressBar->setTextVisible(false);
    progressBar->setFixedSize(12,231);
    progressBar->setValue(0);


    stationLabel = new QLabel();
    stationLabel->setText("到站距离\n0m");
    stationLabel->setAlignment(Qt::AlignHCenter);
    stationLabel->setObjectName("stationLabel");

    //添加到mode
    vLayout->addWidget(dwellTimeString,65);
    vLayout->addWidget(distanceString,35);
    vLayout->addWidget(barWidget,231);
    vLayout->addWidget(stationLabel,40);
}
